package com.lecture.javamode.singleton;

public class SingletonDemo3 {

    private static volatile SingletonDemo3 singletonDemo2;

    private String name;

    private SingletonDemo3() {
        name = "张三";
    }

    public static SingletonDemo3 getInstance() {
        if (singletonDemo2 == null) {
            synchronized (SingletonDemo3.class) {
                if (singletonDemo2 == null) {
                    singletonDemo2 = new SingletonDemo3();
                }
            }
        }
        return singletonDemo2;
    }

    public String getName() {
        return name;
    }

}
